package com.credithc.eagleeye.spring.starter;
import com.credithc.eagleeye.plugins.rabbitmq.EagleEyeRabbitPublishAspect;
import com.credithc.eagleeye.plugins.rabbitmq.EagleEyeSpringRabbitDecorator;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
 * 描 述: <br/>
 * 作 者: zhangjin<br/>
 * 创 建：2019年10月22日<br/>
 * 版 本：v1.0.0<br>
 * <p>
 * 历 史: (版本) 作者 时间 注释 <br/>
 */
@Configuration
@ConditionalOnClass(name={"org.springframework.amqp.rabbit.core.RabbitTemplate"})
public class EagleEyeRabbitAutoConfiguration {

    @Bean
    @ConditionalOnMissingBean
    static EagleEyeRabbitBeanPostProcessor eagleEyeRabbitBeanPostProcessor(BeanFactory beanFactory) {
        return new EagleEyeRabbitBeanPostProcessor(beanFactory);
    }

    @Bean
    @ConditionalOnMissingBean
    EagleEyeSpringRabbitDecorator eagleEyeSpringRabbitDecorator() {
        return new EagleEyeSpringRabbitDecorator();
    }

    @Bean
    @ConditionalOnClass(name = "org.aspectj.lang.ProceedingJoinPoint")
    @ConditionalOnMissingBean(EagleEyeRabbitPublishAspect.class)
    public EagleEyeRabbitPublishAspect eagleEyeProducerAspect() {
        return new EagleEyeRabbitPublishAspect();
    }

}

